package com.inkyi.assistant.app.component.rsyntax.action;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * 自动换行
 *
 * @author lihongkun
 * @date 2024/09/10
 */
public class WordWrapAction implements ItemListener {
    private final RSyntaxTextArea textArea;

    public WordWrapAction(RSyntaxTextArea textArea) {
        this.textArea = textArea;
    }

    @Override
    public void itemStateChanged(ItemEvent e) {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            textArea.setLineWrap(true);
        } else if (e.getStateChange() == ItemEvent.DESELECTED) {
            textArea.setLineWrap(false);
        }
    }
}
